package guaduation.listener;

import guaduation.exception.FailException;
import guaduation.processTemplate.AbstractProcessTemplate;
import guaduation.processTemplate.TemplateFactory;

public class RFIDListener extends AbstractPortListener {

    @Override
    public void onReadException(Exception e) {
        logger.error("错误:" + e.toString());
    }

    @Override
    public void onReceive(byte[] data) {
        logger.info("接收");
        AbstractProcessTemplate template =
                TemplateFactory.createTemplate("guaduation.processTemplate.RFIDProcessTemplate");
        try {
            template.encapusulate(data);
            template.processData();
            template.doNetwork();
        } catch (FailException e) {
//            e.printStackTrace();
        }
    }
}
